home *** CD-ROM | disk | FTP | other *** search
- ' Program EX_0807.BAS
- ' Listing 18B - see documentation in TUTOR.SSS
-
- const ARRIVL = 1, STARTA = 2, ENDACT = 3, NEXTAC = 4
- const TIMEL = 120
-
- common shared n, countr, server, ecode, a1$, b$, t0#
-
- declare sub prime ()
- declare sub resque ()
- declare sub endper ()
-
- rem $include: 'SSSB.H'
-
- call prime
-
- do
- ecode = NEXTEV
- if ecode > 0 then
- select case ecode
-
- case ARRIVL
- if n = countr * TIMEL then endper
- n = n + 1
- print using b$; T;
- locate , 1
- SETA 1, EX(.9)
- CREATE EX(1), n
- SCHED 0, NEXTAC, IDE
-
- case NEXTAC
- if server > 0 then
- SCHED 0, STARTA, IDE
- else
- QUEUE 1, 0
- end if
-
- case STARTA
- SCHED A(1), ENDACT, IDE
- server = server - 1
- TALLY 1, server
-
- case ENDACT
- DISPOS
- server = server + 1
- TALLY 1, server
- if NQ(1) > 0 then
- REMVFQ 1, 1
- SCHED 0, STARTA, IDE
- end if
-
- end select
- end if
- loop while ecode > 0
-
- end
-
- sub endper
- select case countr
- case 0
- SETSEE 777
- SETANT 0
-
- case 1
- print "# average avail.s duration "
-
- case 2
- print using a1$; countr; QAVG(1); SAVG(1); T - t0#
-
- case 3
- print using a1$; countr; QAVG(1); SAVG(1); T - t0#
- QUEUE 2, 0
- resque
- server = 1
- REMVFQ 2, 1
- SETSEE 777
- SETANT 1
-
- case 4
-
- case 5
- print using a1$; countr; QAVG(1); SAVG(1); T - t0#
-
- case 6
- print using a1$; countr; QAVG(1); SAVG(1); T - t0#
- SIMEND 0
-
- end select
-
- CLEARS 0
- CLEARQ 1
- countr = countr + 1
- t0# = T
- end sub
-
- sub prime
- a1$ = "# #####.# ###.### #####.## "
- b$ = "Simulated time: #####.## "
- n = 0
- countr = 0
- server = 1
- t0# = 0
- INIQUE 2, 1, 1
- title$ = "bus "
- INISTA 1, sadd(title$), 1, 0, 0, 0
- TALLY 1, server
- CREATE 0, n
- end sub
-
- sub resque
- CLEARS 0
- CLEARQ 0
- while NQ(1) > 0
- REMVFQ 1, 1
- DISPOS
- wend
- while NC > 0
- REMVFC 1
- DISPOS
- wend
- end sub
-